package phongtro.webservice;

import com.google.gson.Gson;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import model.service.*;
import model.entity.*;
import java.util.*;
import javax.ws.rs.PathParam;
import model.dao.PhongTroDAO;
import model.dao.QuanDAO;
import org.json.JSONArray;
import org.json.JSONObject;



@Path("phongtrowebservice")
public class PhongTroService {

    PhongTroDAOService phongService = PhongTroDAO.getInstance();

  @GET
    @Path("/listphong")
    public String getListPhong() {
        try {
            List<PhongTro> listPhong = phongService.getAllPhongTro();
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    
    @GET
    @Path("/listphonghaichau")
    public String listphongHaiChau() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(1);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    @GET
    @Path("/listphongthanhkhe")
    public String listphongThanhKhe() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(2);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    @GET
    @Path("/listphongsontra")
    public String listphongSonTra() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(3);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    @GET
    @Path("/listphongnguhanhson")
    public String listphongNguHanhSon() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(4);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }

    
    @GET
    @Path("/listphonglienchieu")
    public String listphongLienChieu() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(5);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    @GET
    @Path("/listphongcamle")
    public String listphongCamLe() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(6);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    @GET
    @Path("/listphonghoavang")
    public String listphongHoaVang() {
        try {
            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(7);
      //      List<PhongTro> list = phongService.getPhongTrobyQUan(1);
            Gson jGson = new Gson();
            return jGson.toJson(listPhong);
        } catch (Exception e) {
        }
        return null;
    }
    @GET
//    @Path("/danhgia/{maphong}/{diemdanhgia}/{diachiMAC}")
    @Path("/danhgia/{maphong}/{danhgia}/{songuoidanhgia}/{diachiMAC}")

//    public String danhgia(@PathParam("maphong") int maphong, @PathParam("diemdanhgia") int diemdanhgia, @PathParam("diachiMAC") String diachiMAC) {
    public String danhgia(@PathParam("maphong") int maphong, @PathParam("danhgia") float danhgia,@PathParam("songuoidanhgia") int songuoidanhgia, @PathParam("diachiMAC") String diachiMAC) {


             System.out.println(maphong);
             System.out.println(danhgia);
             System.out.println(diachiMAC);
             System.out.println(songuoidanhgia);
            if(phongService.update_danhgia(maphong,danhgia,songuoidanhgia,diachiMAC)==true){
                System.out.println("Thành Công!");
                return "";
            }else
                 System.out.println("Thất bại");
            return "";

    }
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
//  @GET
//    @Path("/infoPhongtro")
//    public String getThongtinPTbyMaPhongTro() {
//        try {
//            List<PhongTro> listPhong = phongService.getThongtinPTbyMaPhongTro(maphongtro);
//            Gson jGson = new Gson();
//            return jGson.toJson(listPhong);
//        } catch (Exception e) {
//        }
//        return null;
//    }

//  @GET
//    @Path("/listphongbyquan")
//    public String getListPhongbyQuan() {
//        try {
//            
//            List<PhongTro> listPhong = phongService.getPhongTrobyQUan(maquan);
//            Gson jGson = new Gson();
//            return jGson.toJson(listPhong);
//        } catch (Exception e) {
//        }
//        return null;
//    }

}